package com.davidhigenbottam.HeatMap.client;

import com.davidhigenbottam.HeatMap.shared.ColourBand;

public class ColourBands {
	public static final String OPACITY = "bb";

	// first 5 are band colours 6th is no data colour
	public static final String[][] BGR = { { "FB", "F8", "ED" },
			{ "E2", "E2", "B2" }, { "A4", "C2", "66" }, { "5F", "A2", "2C" },
			{ "2C", "6D", "00" }, { "AA", "AA", "AA" } };

	private static String bgr(int i) {
		return BGR[i][0] + BGR[i][1] + BGR[i][2];
	}
	public static String opacitybgr(int i) {
		return OPACITY+BGR[i][0] + BGR[i][1] + BGR[i][2];
	}

	private static String rgb(int i) {
		return BGR[i][2] + BGR[i][1] + BGR[i][0];
	}

	public static String keyHTML() {

		return "<table><tr>" + "<td style=\"background-color:#" + rgb(0)
				+ ";width:80px;\">&nbsp;</td>"
				+ "<td style=\"background-color:#" + rgb(1)
				+ ";width:80px;\">&nbsp;</td>"
				+ "<td style=\"background-color:#" + rgb(2)
				+ ";width:80px;\">&nbsp;</td>"
				+ "<td style=\"background-color:#" + rgb(3)
				+ ";width:80px;\">&nbsp;</td>"
				+ "<td style=\"background-color:#" + rgb(4)
				+ ";width:80px;\">&nbsp;</td>"
				+ "<td style=\"text-align:center;background-color:#" + rgb(5)
				+ ";width:80px;\">No Data</td></tr></table>";
	}

	public static String fetchProvinceColor(ColourBand cb) {

		String bgr;
		switch (cb) {
		case FIRST:
			bgr = bgr(0);
			break;
		case SECOND:
			bgr = bgr(1);
			break;
		case THIRD:
			bgr = bgr(2);
			break;
		case FOURTH:
			bgr = bgr(3);
			break;
		case FIFTH:
			bgr = bgr(4);
			break;
		case NODATA:
			bgr = bgr(5);
			break;
		default:
			bgr = bgr(5);
			break;

		}
		return OPACITY + bgr;

	}
}
